package com.dc.project.entity.vo;

import com.dc.project.entity.po.TemplateDetail;
import com.own.component.common.base.entity.vo.BaseSortVo;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * TemplateDetailVo
 *
 * @author chenxueli
 * @date 2025-03-19 13:09:50
 */
@Schema(title = "模板详情" + ConstantBeanSuffix.VO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class TemplateDetailVo extends BaseSortVo<TemplateDetail> implements Serializable {

    @Schema(title = "模板id")
    private Long templateId;

    @Schema(title = "模板详情标题")
    private String title;

    @Schema(title = "模板详情描述")
    private String description;

    @Schema(title = "生成文件的额外提示词")
    private String generatePrompt;

    @Schema(title = "生成文件的处理方式 0=不生成 1=大模型自定义生成 2=根据模板附件生成 3=提取原始材料")
    private Integer generateType;

    /**
     * 构造方法
     *
     * @param entity 原对象
     */
    public TemplateDetailVo(@NonNull TemplateDetail entity) {
        super(entity);
        this.templateId = entity.getFkTemplateId();
        this.title = entity.getTitle();
        this.description = entity.getDescription();
        this.generatePrompt = entity.getGeneratePrompt();
        this.generateType = entity.getGenerateType();
    }

    /**
     * 转po对象
     *
     * @param entity 原对象
     * @return po对象
     */
    @Override
    public TemplateDetail toPo(TemplateDetail entity) {
        if (entity == null) {
            entity = new TemplateDetail();
        }
        entity.setFkTemplateId(this.templateId);
        entity.setTitle(this.title);
        entity.setDescription(this.description);
        entity.setGeneratePrompt(this.generatePrompt);
        entity.setGenerateType(this.generateType);
        return super.toPo(entity);
    }

}
